﻿#ifndef PST_CENTERWIDGET_H
#define PST_CENTERWIDGET_H

#include "T_BasePage.h"
#include "InfomationCurve2DBasical.h"
#include "CommonDefines.h"

class vtkProp;
class ElaTabWidget;
class ElaTreeView;
class QStandardItem;
namespace pst
{
    class Graph2D;
    class Graph3D;
    class GraphSurface;

    /// @brief 中心视图 管理工程树，tab标签（每个标签是一个后处理窗口）
    class CenterWidget : public T_BasePage
    {
        Q_OBJECT
    public:
        Q_INVOKABLE explicit CenterWidget(QWidget* parent = nullptr);
        ~CenterWidget();
        QWidget* getCurrentGraphWindow();
        void setCurrentGraphWindow(QWidget* currentW);

        void showContextMenu(const QPoint& pos);

        void addToCurrentGraph();

        // void addNewProject();
        void addFileNode(QStandardItem* item);
        //是否设置添加新窗口后自动设置为当前展示窗口
        void setAddedGraphWindowActiveAuto(bool activeAuto);
        bool getAddedGraphWindowActiveAuto();


        void addLineToGrapg2D(Graph2D* _graph2D, const QPair<QString,
            QVector<double>>&x, const QPair<QString, QVector<double>>& y);

        void addLineToGrapg2D(InfomationCurve2DBasical& info);

        void addLinesToNewGrapg2DWindow(QList<InfomationCurve2DBasical>& infos, bool useNewWindow);

        bool saveScreenShot(const QString& path);

        //2D graph管理
        Graph2D* addNewGraph2D();

        inline ElaTreeView* GetTreeView() const {
            return m_treeView;
        };

        //3D graph管理
        Graph3D* addNewGraph3D();
        /// @brief 一个三维窗口添加多个图
        void addImageToNewGraph3DWindow(QList<InfomationGraph3DBasical>& infos, bool useNewWindow);
        void addImageToGraph3D(InfomationGraph3DBasical& info);

        // graph surface 管理
        GraphSurface* addNewGraphSurface();
        void addImageToNewSurfaceWindow(const QString& fileName);

        void addPropToGraph3D(Graph3D* graph, QList<vtkProp*> props);

        //void setCurrentTab(Graph2D* _graph2D);
        QList<QStandardItem*> getSelectedItems();
    signals:
        void signal_fileClicked(const QList<QStandardItem*>& indexs);
        void signal_addToCurrentGraph(const QList<QStandardItem*>& indexs);

    private:



    public slots:
        //void slot_fileClicked(const QModelIndex& index);
        void slot_addLinesToNewGrapg2DWindow(QList<InfomationCurve2DBasical>& infos);
    private:
        /// @brief 左侧项目树
        ElaTreeView* m_treeView{ nullptr };
        /// @brief 右侧的后处理窗口
        ElaTabWidget* m_tabWidget{ nullptr };
        //Graph2D* _graph2D;

        QList<Graph2D*> m_graph2DList;
        bool m_isActiveAuto{ true };
        int m_graph2DCount{ 0 };
        QList<Graph3D*> m_graph3DList;
    };

}
#endif // T_NAVIGATION_H
